package com.flyduck.vueshop.product.remote.controller;

import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.sotoken.annotation.InnerAuth;
import com.flyduck.vueshop.product.remote.service.RemoteProductService;
import com.flyduck.vueshop.product.vo.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * RemoteSkuStockController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-15
 */
@RestController
@RequestMapping("/product/remote/product")
public class RemoteProductController {

    @Resource
    private RemoteProductService remoteProductService;

    @InnerAuth
    @PostMapping("/getProductById/{id}")
    public Result<RemoteProductRespVO> getProductById(@PathVariable("id") Long id){
        RemoteProductRespVO remoteProductRespVO = remoteProductService.getProductById(id);
        return Result.success(remoteProductRespVO);
    }

    @InnerAuth
    @GetMapping("/getOnSaleProductList")
    public Result<List<RemoteProductRespVO>> getOnSaleProductList(){
        List<RemoteProductRespVO> remoteProductRespVOList = remoteProductService.getOnSaleProductList();
        return Result.success(remoteProductRespVOList);
    }

    @InnerAuth
    @GetMapping("/batchUpdateProduct")
    Result<Void> batchUpdateProduct(@RequestBody List<RemoteProductUpdateReqVO> remoteProductUpdateReqVOList){
        remoteProductService.batchUpdateProduct(remoteProductUpdateReqVOList);
        return Result.success();
    }
}
